<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- /fasttmp/mkdist-qt-4.3.5-1211793125/qtopia-core-opensource-src-4.3.5/src/qt3support/sql/q3sqlpropertymap.cpp -->
<head>
  <title>Qt 4.3: Q3SqlPropertyMap Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="modules.html"><font color="#004faf">Modules</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
<td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">Q3SqlPropertyMap Class Reference<br /><sup><sup>[<a href="qt3support.html">Qt3Support</a> module]</sup></sup></h1>
<p>The Q3SqlPropertyMap class is used to map widgets to SQL fields. <a href="#details">More...</a></p>
<pre> #include &lt;Q3SqlPropertyMap&gt;</pre><p><b>This class is part of the Qt 3 support library.</b> It is provided to keep old source code working. We strongly advise against using it in new code. See <a href="porting4.html#qsqlpropertymap">Porting to Qt 4</a> for more information.</p>
<ul>
<li><a href="q3sqlpropertymap-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h3>Public Functions</h3>
<ul>
<li><div class="fn"/><b><a href="q3sqlpropertymap.html#Q3SqlPropertyMap">Q3SqlPropertyMap</a></b> ()</li>
<li><div class="fn"/>virtual <b><a href="q3sqlpropertymap.html#dtor.Q3SqlPropertyMap">~Q3SqlPropertyMap</a></b> ()</li>
<li><div class="fn"/>void <b><a href="q3sqlpropertymap.html#insert">insert</a></b> ( const QString &amp; <i>classname</i>, const QString &amp; <i>property</i> )</li>
<li><div class="fn"/>QVariant <b><a href="q3sqlpropertymap.html#property">property</a></b> ( QWidget * <i>widget</i> )</li>
<li><div class="fn"/>void <b><a href="q3sqlpropertymap.html#remove">remove</a></b> ( const QString &amp; <i>classname</i> )</li>
<li><div class="fn"/>virtual void <b><a href="q3sqlpropertymap.html#setProperty">setProperty</a></b> ( QWidget * <i>widget</i>, const QVariant &amp; <i>value</i> )</li>
</ul>
<a name="static-public-members"></a>
<h3>Static Public Members</h3>
<ul>
<li><div class="fn"/>Q3SqlPropertyMap * <b><a href="q3sqlpropertymap.html#defaultMap">defaultMap</a></b> ()</li>
<li><div class="fn"/>void <b><a href="q3sqlpropertymap.html#installDefaultMap">installDefaultMap</a></b> ( Q3SqlPropertyMap * <i>map</i> )</li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The Q3SqlPropertyMap class is used to map widgets to SQL fields.</p>
<p>The SQL module uses Qt <a href="properties.html">object properties</a> to insert and extract values from editor widgets.</p>
<p>This class is used to map editors to SQL fields. This works by associating SQL editor class names to the properties used to insert and extract values to/from the editor.</p>
<p>For example, a <a href="qlineedit.html">QLineEdit</a> can be used to edit text strings and other data types in Q3DataTables or Q3SqlForms. Several properties are defined in <a href="qlineedit.html">QLineEdit</a>, but only the <i>text</i> property is used to insert and extract text from a <a href="qlineedit.html">QLineEdit</a>. Both <a href="q3datatable.html">Q3DataTable</a> and <a href="q3sqlform.html">Q3SqlForm</a> use the global Q3SqlPropertyMap for inserting and extracting values to and from an editor widget. The global property map defines several common widgets and properties that are suitable for many applications. You can add and remove widget properties to suit your specific needs.</p>
<p>If you want to use custom editors with your <a href="q3datatable.html">Q3DataTable</a> or <a href="q3sqlform.html">Q3SqlForm</a>, you must install your own Q3SqlPropertyMap for that table or form. Example:</p>
<pre> Q3SqlPropertyMap *myMap  = new Q3SqlPropertyMap();
 Q3SqlForm        *myForm = new Q3SqlForm(this);
 MyEditor myEditor(this);

<span class="comment"> //</span> Set the Q3SqlForm's record buffer to the update buffer of
<span class="comment"> //</span> a pre-existing Q3SqlCursor called 'cur'.
 myForm-&gt;setRecord(cur-&gt;primeUpdate());

<span class="comment"> //</span> Install the customized map
 myMap-&gt;insert(&quot;MyEditor&quot;, &quot;content&quot;);
 myForm-&gt;installPropertyMap(myMap); <span class="comment">//</span> myForm now owns myMap
 ...
<span class="comment"> //</span> Insert a field into the form that uses a myEditor to edit the
<span class="comment"> //</span> field 'somefield'
 myForm-&gt;insert(&amp;myEditor, &quot;somefield&quot;);

<span class="comment"> //</span> Update myEditor with the value from the mapped database field
 myForm-&gt;readFields();
 ...
<span class="comment"> //</span> Let the user edit the form
 ...
<span class="comment"> //</span> Update the database fields with the values in the form
 myForm-&gt;writeFields();
 ...</pre>
<p>You can also replace the global Q3SqlPropertyMap that is used by default. (Bear in mind that Q3SqlPropertyMap takes ownership of the new default map.)</p>
<pre> Q3SqlPropertyMap *myMap = new Q3SqlPropertyMap;

 myMap-&gt;insert(&quot;MyEditor&quot;, &quot;content&quot;);
 Q3SqlPropertyMap::installDefaultMap(myMap);
 ...</pre>
<p>See also <a href="q3datatable.html">Q3DataTable</a>, <a href="q3sqlform.html">Q3SqlForm</a>, and <a href="q3sqleditorfactory.html">Q3SqlEditorFactory</a>.</p>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="Q3SqlPropertyMap"></a>Q3SqlPropertyMap::Q3SqlPropertyMap ()</h3>
<p>Constructs a <a href="q3sqlpropertymap.html">Q3SqlPropertyMap</a>.</p>
<p>The default property mappings used by Qt widgets are:</p>
<p><table align="center" cellpadding="2" cellspacing="1" border="0">
<thead><tr valign="top" class="qt-style"><th>Widgets</th><th>Property</th></tr></thead>
<tr valign="top" class="odd"><td><a href="qcheckbox.html">QCheckBox</a>, <a href="qradiobutton.html">QRadioButton</a></td><td>checked</td></tr>
<tr valign="top" class="even"><td><a href="qcombobox.html">QComboBox</a>, <a href="q3listbox.html">Q3ListBox</a></td><td>currentItem</td></tr>
<tr valign="top" class="odd"><td><a href="q3dateedit.html">Q3DateEdit</a></td><td>date</td></tr>
<tr valign="top" class="even"><td><a href="q3datetimeedit.html">Q3DateTimeEdit</a> <a href="qdatetimeedit.html">QDateTimeEdit</a></td><td>dateTime</td></tr>
<tr valign="top" class="odd"><td><a href="qtextbrowser.html">QTextBrowser</a></td><td>source</td></tr>
<tr valign="top" class="even"><td><a href="qabstractbutton.html">QAbstractButton</a>, <a href="qdial.html">QDial</a>, <a href="qlabel.html">QLabel</a>, <a href="qlineedit.html">QLineEdit</a>, <a href="q3multilineedit.html">Q3MultiLineEdit</a>, <a href="qpushbutton.html">QPushButton</a>, <a href="qtextedit.html">QTextEdit</a>,</td><td>text</td></tr>
<tr valign="top" class="odd"><td><a href="q3timeedit.html">Q3TimeEdit</a></td><td>time</td></tr>
<tr valign="top" class="even"><td><a href="qlcdnumber.html">QLCDNumber</a>, <a href="qscrollbar.html">QScrollBar</a> <a href="qslider.html">QSlider</a>, <a href="qspinbox.html">QSpinBox</a></td><td>value</td></tr>
</table></p>
<h3 class="fn"><a name="dtor.Q3SqlPropertyMap"></a>Q3SqlPropertyMap::~Q3SqlPropertyMap ()&nbsp;&nbsp;<tt> [virtual]</tt></h3>
<p>Destroys the <a href="q3sqlpropertymap.html">Q3SqlPropertyMap</a>.</p>
<p>Note that if the <a href="q3sqlpropertymap.html">Q3SqlPropertyMap</a> is installed with installPropertyMap() the object it was installed into, e.g&#x2e; the <a href="q3sqlform.html">Q3SqlForm</a>, takes ownership and will delete the <a href="q3sqlpropertymap.html">Q3SqlPropertyMap</a> when necessary.</p>
<h3 class="fn"><a name="defaultMap"></a>Q3SqlPropertyMap * Q3SqlPropertyMap::defaultMap ()&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Returns the application global <a href="q3sqlpropertymap.html">Q3SqlPropertyMap</a>.</p>
<h3 class="fn"><a name="insert"></a>void Q3SqlPropertyMap::insert ( const <a href="qstring.html">QString</a> &amp; <i>classname</i>, const <a href="qstring.html">QString</a> &amp; <i>property</i> )</h3>
<p>Insert a new classname/property pair, which is used for custom SQL field editors. There <i>must</i> be a <a href="qobject.html#Q_PROPERTY">Q_PROPERTY</a>() clause in the <i>classname</i> class declaration for the <i>property</i>.</p>
<h3 class="fn"><a name="installDefaultMap"></a>void Q3SqlPropertyMap::installDefaultMap ( Q3SqlPropertyMap * <i>map</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Replaces the global default property map with <i>map</i>. All <a href="q3datatable.html">Q3DataTable</a> and <a href="q3sqlform.html">Q3SqlForm</a> instantiations will use this new map for inserting and extracting values to and from editors. <i><a href="q3sqlpropertymap.html">Q3SqlPropertyMap</a> takes ownership of <i>map</i>, and destroys it when it is no longer needed.</i></p>
<h3 class="fn"><a name="property"></a><a href="qvariant.html">QVariant</a> Q3SqlPropertyMap::property ( <a href="qwidget.html">QWidget</a> * <i>widget</i> )</h3>
<p>Returns the mapped property of <i>widget</i> as a <a href="qvariant.html">QVariant</a>.</p>
<p>See also <a href="q3sqlpropertymap.html#setProperty">setProperty</a>().</p>
<h3 class="fn"><a name="remove"></a>void Q3SqlPropertyMap::remove ( const <a href="qstring.html">QString</a> &amp; <i>classname</i> )</h3>
<p>Removes <i>classname</i> from the map.</p>
<h3 class="fn"><a name="setProperty"></a>void Q3SqlPropertyMap::setProperty ( <a href="qwidget.html">QWidget</a> * <i>widget</i>, const <a href="qvariant.html">QVariant</a> &amp; <i>value</i> )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
<p>Sets the property of <i>widget</i> to <i>value</i>.</p>
<p>See also <a href="q3sqlpropertymap.html#property">property</a>().</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%">Copyright &copy; 2008 <a href="trolltech.html">Trolltech</a></td>
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt 4.3.5</div></td>
</tr></table></div></address></body>
</html>
